package com.jason.rtsp.runner;

import com.jason.rtsp.server.NettyVideoServer;
import lombok.extern.slf4j.Slf4j;
import org.bytedeco.javacpp.Loader;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * @创建人 zhouhx
 * @创建时间 2023/8/31 15:19
 * @描述 RSTP服务
 */
@Slf4j
@Component
public class ServerRunner implements CommandLineRunner {

    @Autowired
    private NettyVideoServer nettyVideoServer;

    @Override
    public void run(String... args) throws Exception {
        log.info("启动netty video server服务...");
        nettyVideoServer.start();
    }

    @PostConstruct
    public void loadFFmpeg(){
        log.info("正在加载ffmpg...");
        String ffmpeg = Loader.load(org.bytedeco.ffmpeg.ffmpeg.class);
        log.info("ffmpeg:"+ffmpeg);
        System.setProperty("ffmpeg",ffmpeg);
        log.info("初始化成功,ffmpeg路径：{}",System.getProperty("ffmpeg"));
    }
}
